<script setup>
import { ref, onMounted } from 'vue'
import { artGetChannelsService } from '@/api/article'
//获取分类列表
const channelList = ref([])
onMounted(async () => {
  //获取分类列表数据
  const { data } = await artGetChannelsService()
  channelList.value = data
})
//获取父组件属性
defineProps({
  modelValue: {
    type: [Number, String]
  }
})
const emit = defineEmits(['update:modelValue'])
</script>
<template>
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
  >
    <!-- $event是该事件的默认参数 -->
    <el-option
      v-for="item in channelList"
      :key="item.id"
      :label="item.cate_name"
      :value="item.id"
    ></el-option>
  </el-select>
</template>
<style lang="scss" scoped></style>
